#include <gtk/gtk.h>
#include <stdarg.h>

#include "main.h"

#include "dialogs.h"

void dialog_ok(gchar *format, ...) {
    char tmp[1024];

    va_list ap;
    va_start(ap, format);
    vsnprintf(tmp, 1024, format, ap);
    va_end(ap);

    GtkWidget *dialog=gtk_message_dialog_new(
        NULL,
        GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
        GTK_MESSAGE_INFO,
        GTK_BUTTONS_OK,
        tmp
    );
    gtk_dialog_run(GTK_DIALOG(dialog));
    gtk_widget_destroy(dialog);
}

void dialog_error(gchar *format, ...) {
    char tmp[1024];

    va_list ap;
    va_start(ap, format);
    vsnprintf(tmp, 1024, format, ap);
    va_end(ap);

    GtkWidget *dialog=gtk_message_dialog_new(
        NULL,
        GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
        GTK_MESSAGE_ERROR,
        GTK_BUTTONS_OK,
        tmp
    );
    gtk_dialog_run(GTK_DIALOG(dialog));
    gtk_widget_destroy(dialog);
}

